<template>
  <!--
  <iframe v-if="routerPath" :src="routerPath" class="iframe" ref="iframe" v-loading.fullscreen.lock="fullscreenLoading" ></iframe>
  <iframe v-else :src="$route.query.src" class="iframe" ref="iframe" v-loading.fullscreen.lock="fullscreenLoading" ></iframe>
  -->
  <html>
    <body>
      <iframe :src="routerPath" width="100%" height="100%" frameborder="0" name="_blank"></iframe>
    </body>
  </html>
</template>

<script>
// sidemenu 模式可以, top 模式 iframe 样式待修正
import { mixin, mixinDevice } from '@/utils/mixin'
export default {
  name: 'AIframe',
  mixins: [mixin, mixinDevice],
  data () {
    return {
      fullscreenLoading: false
    }
  },
  created () {
    this.fullscreenLoading = true
  },
  mounted () {
    // this.iframeInit()
    window.onresize = () => {
      // this.iframeInit()
    }
  },
  props: {
    routerPath: {
      type: String,
      default: null
    }
  },
  components: {},
  methods: {
    iframeInit () {
      if (this.layout === 'sidemenu') {
        return
      }
      const that = this
      const iframe = this.$refs.iframe
      const clientHeight = document.documentElement.clientHeight - (this.multiTab ? 228 : 188)
      iframe.style.height = `${clientHeight}px`
      if (iframe.attachEvent) {
        iframe.attachEvent('onload', () => {
          that.fullscreenLoading = false
        })
      } else {
        iframe.onload = () => {
          that.fullscreenLoading = false
        }
      }
    }
  }
}
</script>

<style lang="less" scoped>
  .iframe {
    width: 100%;
    height: 100%;
    border: 0;
    overflow: hidden;
    box-sizing: border-box;
    background: white;
   }
  body {margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;overflow: hidden;}
</style>
